<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    //   对数组设置代理
    const lessons = [
      { title: "媒体查询响应式布局", CATEGORY: "css" },
      { title: "FLEX弹性盒模型", CATEGORY: "css" },
      { title: "MYSQL多表查询随意操作", CATEGORY: "mysql" },
    ];
    let proxy = new Proxy(lessons, {
      get(array, key) {
        const title = array[key].title;
        const len = 10;
        array[key].title =
          title.length > len ? title.substr(0, len) + ".".repeat(3) : title;
        return array[key];
      },
    });
    console.log(JSON.stringify(proxy[2], null, 2));
  </script>
</html>
